/**
 * Created By: sisopipo Project Team
 * Created Date: Feb 25, 2011
 */
package com.sisopipo.assetsportal.context.impl;

import com.sisopipo.assetsportal.context.IAppSessionContext;
import com.sisopipo.assetsportal.security.IOrganizationManager;
import com.sisopipo.assetsportal.security.domain.User;
import com.sisopipo.core.context.impl.SessionContextImpl;

/**
 * @author ribin
 * @version 1.0
 */
public class AppSessionContextImpl extends SessionContextImpl implements IAppSessionContext {

	private IOrganizationManager organizationManager;

	public User getUser() {
		// TODO can be improved
		String userId = getUserId();
		return getUser(userId);
	}

	private User getUser(String userId) {
		if (userId == null || userId.length() == 0)
			return null;
		return organizationManager.getUser(userId);
	}

	public void setOrganizationManager(IOrganizationManager organizationManager) {
		this.organizationManager = organizationManager;
	}

}
